import { GUIComponent } from "../../../../../com/mui/controls/GUIComponent";
import { Language } from "../../../../../extend/language/Language";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { AvatarUploadPanel } from "../AvatarUploadPanel";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SPlayerMarry } from "../../../../../Message/Public/SPlayerMarry";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { CareerUtil } from "../../common/util/CareerUtil";
import { PlayerRuneFightBtn } from "./PlayerRuneFightBtn";
import { CareerConfig } from "../../../resource/CareerConfig";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { EMarryStatus } from "../../../../../Message/Game/EMarryStatus";
import { Cache } from "../../../cache/Cache";
import { ECareer } from "../../../../../Message/Public/ECareer";
import { SPlayerGuildInfo } from "../../../../../Message/Game/SPlayerGuildInfo";
import { TextInput } from "../../../../../fl/controls/TextInput";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class RoleInfoPanel
    
    export  class RoleInfoPanel extends GUIComponent
    {
        constructor()
        {
            super();
            this._infoNameArr = [Language.getString(30007), Language.getString(30012), Language.getString(30009), Language.getString(30164), Language.getString(30011), ""];
            this._nameTxtArray = [];
            this._valueTxtArrar = [];
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            this._avatarUpload.mode = arg1;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            loc1.setSize(390, 62);
            loc1.x = 0;
            loc1.y = 0;
            this.addChild(loc1);
            var loc2=new GTextFormat("", 12, 16705250);
            this.createAttrTextField(75, 5, loc2, true);
            this.createAttrTextField(110, 6, GlobalStyle.textFormat2);
            this._titleTxtInput = ObjCreate.createGTextInput(115, 40, 170, 20, this);
            this._titleTxtInput.text = Language.getString(30013);
            this._titleTxtInput.editable = false;
            this._gloryBtn = ObjCreate.createGButton("", 290, 40, 18, 18, this, "AddBtn");
            this._gloryBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGloryBtnClickHandler);
            this._avatarUpload = new AvatarUploadPanel();
            this._avatarUpload.x = 20;
            this._avatarUpload.y = 12;
            addChild(this._avatarUpload);
            return;
        }

        /* internal  */createAttrTextField(arg1: int, arg2: int, arg3: Object /* flash.text.TextFormat */, arg4: Boolean=false): void
        {
            var loc1=null;
            var loc3=0;
            var loc2=arg1;
            loc3 = arg2;
            var loc4=0;
            while (loc4 < this._infoNameArr.length) 
            {
                (loc1 = new Object /* flash.text.TextField */()).x = loc2;
                loc1.y = loc3;
                loc1.height = 20;
                loc1.width = 50;
                loc1.selectable = false;
                loc1.defaultTextFormat = arg3;
                if (arg4) 
                {
                    loc1.text = this._infoNameArr[loc4];
                    loc1.filters = [FilterConst.glowFilter];
                    this._nameTxtArray.push(loc1);
                }
                else 
                {
                    loc1.text = "0000";
                    this._valueTxtArrar.push(loc1);
                }
                loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
                this.addChild(loc1);
                loc2 = loc2 + 110;
                if ((loc4 + 1) % 2 == 0) 
                {
                    loc2 = arg1;
                    loc3 = arg2 + 18 * (loc4 + 1) / 2;
                }
                ++loc4;
            }
            return;
        }

        /* internal  */onRuneTxtLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.Role_LookupRune, this._mode));
            return;
        }

        public setInfoText(arg1: string, arg2: int, arg3: int, arg4: int, arg5: int, arg6: string, arg7: int, arg8: SPlayerMarry): void
        {
            var loc5=null;
            if (this._mode == GModuleEvent.Mode_Other || this._mode == GModuleEvent.Mode_ArenaCross || this._mode == GModuleEvent.Mode_Wrestle) 
            {
                this._gloryBtn.visible = false;
            }
            else 
            {
                this._gloryBtn.visible = true;
            }
            if ((this._mode == GModuleEvent.Mode_Other || this._mode == GModuleEvent.Mode_Self) && CareerUtil.isGradeCareer(arg2) && arg3 >= 65) 
            {
                if (this._runeFightBtn == null) 
                {
                    this._runeFightBtn = new PlayerRuneFightBtn();
                    this._runeFightBtn.x = 310;
                    this._runeFightBtn.y = 5;
                }
                this._runeFightBtn.mode = this._mode;
                addChild(this._runeFightBtn);
            }
            else if (this._runeFightBtn && this._runeFightBtn.parent) 
            {
                removeChild(this._runeFightBtn);
            }
            var loc1=CareerConfig.instance.getInfoByCode(arg2).name;
            var loc2=GameDefConfig.instance.getECamp(arg4);
            if (arg6 == "") 
            {
                arg6 = Language.getString(30002);
            }
            var loc3=GameDefConfig.instance.getSex(arg7).name;
            var loc4=Language.getString(30002);
            if (arg8 != null) 
            {
                if (!(arg8.mate == null) && !(arg8.status == EMarryStatus._EMarryStatusNo) && !(arg8.mate.name == "")) 
                {
                    loc4 = arg8.mate.name;
                }
            }
            (this._valueTxtArrar[0] as Object /* flash.text.TextField */).text = loc2;
            (this._valueTxtArrar[1] as Object /* flash.text.TextField */).text = arg5.toString();
            (this._valueTxtArrar[2] as Object /* flash.text.TextField */).text = arg6;
            (this._valueTxtArrar[3] as Object /* flash.text.TextField */).text = loc4;
            (this._valueTxtArrar[4] as Object /* flash.text.TextField */).text = "";
            (this._valueTxtArrar[5] as Object /* flash.text.TextField */).text = "";
            var loc6=0;
            var loc7=this._valueTxtArrar;
            for(loc5 of loc7) 
            {
                loc5.setTextFormat(GlobalStyle.textFormat2);
            }
            return;
        }

        /* internal  */onGloryBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TitleWindowShowOrHide));
            return;
        }

        public updateTitle(): void
        {
            var loc1=Cache.instance.title.currentTitleName;
            if (loc1 == "") 
            {
                loc1 = Language.getString(30013);
            }
            this._titleTxtInput.text = loc1;
            var loc2=Cache.instance.role.entityInfo.career;
            if (this._gloryBtn == null) 
            {
                return;
            }
            if (Cache.instance.role.entityInfo.level >= 10 && !(loc2 == ECareer._ECareerNo) && !(loc2 == ECareer._ECareerNewPlayer)) 
            {
                this._gloryBtn.visible = true;
                this._gloryBtn.enabled = true;
            }
            else 
            {
                this._gloryBtn.visible = false;
            }
            return;
        }

        public setTitleName(arg1: string): void
        {
            if (arg1 == "") 
            {
                arg1 = Language.getString(30013);
            }
            this._titleTxtInput.text = arg1;
            this._gloryBtn.visible = false;
            return;
        }

        public updateSelfGuild(arg1: SPlayerGuildInfo=null): void
        {
            var loc1=Language.getString(30002);
            if (!(arg1 == null) && !(arg1.guildName == "")) 
            {
                loc1 = arg1.guildName;
            }
            (this._valueTxtArrar[2] as Object /* flash.text.TextField */).text = loc1;
            return;
        }

        public updateSex(): void
        {
            return;
        }

        public updateCamp(): void
        {
            var loc1=GameDefConfig.instance.getECamp(Cache.instance.role.entityInfo.camp);
            (this._valueTxtArrar[0] as Object /* flash.text.TextField */).text = loc1;
            return;
        }

        public updateMarryInfo(): void
        {
            var loc1=Cache.instance.marry.playerMarry;
            if (loc1 && !(loc1.status == EMarryStatus._EMarryStatusNo) && !(loc1.mate == null) && !(loc1.mate.name == "")) 
            {
                (this._valueTxtArrar[3] as Object /* flash.text.TextField */).text = loc1.mate.name;
            }
            else 
            {
                (this._valueTxtArrar[3] as Object /* flash.text.TextField */).text = Language.getString(30002);
            }
            return;
        }

        public updateUploadAvatar(arg1: int): void
        {
            this._avatarUpload.updateUploadAvatar(arg1);
            return;
        }

        public updateRuneFight(arg1: string): void
        {
            if (this._runeFightBtn && !(arg1 == "")) 
            {
                this._runeFightBtn.updateRuneFight(arg1);
            }
            return;
        }

        /* internal */ /* var */_infoNameArr: Array<any>;

        /* internal */ /* var */_nameTxtArray: Array<any>;

        /* internal */ /* var */_valueTxtArrar: Array<any>;

        /* internal */ /* var */_titleTxtInput: TextInput;

        /* internal */ /* var */_gloryBtn: GButton;

        /* internal */ /* var */_petTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_runeFightBtn: PlayerRuneFightBtn;

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_avatarUpload: AvatarUploadPanel;
    }
